home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / lingua13.zip / LINGUA.DOC < prev    next >
Text File  |  1994-03-11  |  11KB  |  271 lines

  1. ---- LINGUA -- MULTILANGUAGE SUPPORT FOR YOUR PROGRAMS -- SHAREWARE ----
  2. -- VERSION 1.3 -- (C) 1994 -- SICHEMSOFT -- WAGENINGEN -- NETHERLANDS --
  3.  
  4. The LINGUA package is designed to help C-programmers to develop applications
  5. that must be released in multiple languages. The end user gets a program
  6. plus one or more datafiles containing all text in the program. One
  7. datafile for each different language. A language can be chosen at
  8. run time. This thus avoids different .exe files for different languages.
  9. The programmer needs only to compile one executable and to make a text data
  10. file for every supported language. It's also easy to afterwards create
  11. support for yet another language and send the data file to interested
  12. customers.
  13.  
  14.  
  15. HOW IT WORKS
  16.  
  17. The package consists of a program, LINGUA, and a module, UI_TEXT (UI
  18. stands for User Interface). The module should be compiled and linked with
  19. your application program. This module is the same for any language and
  20. is very small (about 3.5KB when compiled with Borland C++ 3.1 under MSDOS).
  21. For every supported language a text file is prepared by the programmer
  22. according to a specified format. This text file is then encrypted by LINGUA,
  23. so users cannot alter and perhaps corrupt it just by editing it. These
  24. encrypted text files are shipped with the application and one of them is
  25. loaded by the module UI_TEXT at run time so the application speaks the
  26. desired language.
  27.  
  28.  
  29. FILES IN THE PACKAGE
  30.  
  31. LINGUA.DOC        You're reading it
  32. LINGUA.EXE        Utility to encrypt .TXT file to .ETF file
  33. LINGUA.C          Source of the above
  34. UI_TEXT.OBJ       Module to be linked with your application (large model)
  35. UI_TEXT.C         Source of the above
  36. LINGDEMO.EXE      Small demo program, usage e.g.: lingdemo francais
  37. LINGDEMO.C        Source of the above
  38. LINGUA.H          Include file for compilation of lingua.c and ui_text.c
  39. ETFTEST.EXE       Utility to show contents of .ETF file
  40. ETFTEST.C         Source of the above
  41. FILES.INC         Include file for ui_text.c, replace if desired (see below)
  42. MAKEFILE          Makefile for the above programs (DOS/BC++)
  43. UNIX.MAK          Makefile for the above programs (UNIX)
  44. NOCR.C            Source for carriage-return/end-of-file remover for UNIX
  45. ENGLISH.TXT       Text files for demo program
  46. FRANCAIS.TXT
  47. DEUTSCH.TXT
  48. NL.TXT
  49. ENGLISH.ETF       Encrypted files for demo program
  50. DEUTSCH.ETF
  51. FRANCAIS.ETF
  52. NL.ETF
  53. UI_TEXT.H         Header file created by LINGUA from .txt files above
  54.  
  55. The file FILES.INC defines all file functions for ui_text.c. FILES.INC uses
  56. the standard C library file functions, like fopen, fseek etc. If you wish
  57. to use other file functions, or C++ streams functions, or whatever, you can
  58. write your own FILES.INC with these functions.
  59.  
  60.  
  61. USAGE
  62.  
  63. First of all, do not use ANY literal strings in your C-source, but
  64. always use identifiers, e.g. not "Press any key" but ANYKEY.
  65. Write your program in any way you like while observing this main rule.
  66.  
  67. At the same time create and maintain a text file with all literal
  68. text for the program in your native language. This file may have any
  69. name but its extension should be .TXT for use by LINGUA. The lines in
  70. this text file should all begin (at the first position!) with an identifier,
  71. corresponding to the identifiers used in the program. Behind the identifier
  72. follows the literal string that should be used in run time. Comment lines
  73. are allowed, they must begin with #. In the literal strings _ signifies
  74. a leading or trailing space, and - denotes an empty string. String arrays,
  75. in which not every item has its own name, are represented by [ after an
  76. identifier's name followed by one or more lines starting with only [.
  77. Multiline strings are represented by / after an identifier's name followed
  78. bye one or more lines starting with only /.
  79.  
  80. By default the text is loaded all at once into memory at the start of the
  81. application (or rather by calling ui_loadtext) and deleted at the end of
  82. the application (ui_unloadtext). If desired, part or all of the text can
  83. be read from the file only when necessary. For this, use the directive
  84. #FILE in the text file (see example below). All text after this directive
  85. will only be loaded when necessary. All text before #FILE remains resident
  86. in memory. You could place all frequently used strings before #FILE and
  87. seldom used or very long strings after #FILE. If #FILE is used the text
  88. file will remain open between ui_loadtext and ui_unloadtext.
  89.  
  90. If you want another character than _ to signify a leading or trailing 
  91. space, you can use the #SPACE directive to change it to any other 
  92. character (see example below).
  93.  
  94.  
  95. Example file english.txt:
  96.  
  97. #english.txt
  98. #empty string
  99. ZEROTH     -
  100. #normal strings
  101. FIRST     one
  102. SECOND    two times
  103. #array
  104. THIRD[    three
  105. [         four
  106. [         five
  107. [         -
  108. [         seven
  109. #leading and trailing spaces
  110. EIGHTH    __eight__
  111. #FILE
  112. #normal string again
  113. NINTH     nine
  114. #multi line string
  115. TENTH/    this is
  116. /         a multiline
  117. /         tenth string
  118. #and change the space character
  119. #SPACE *
  120. ELEVEN    **eleven
  121.  
  122. Whenever any identifier in this text file has been added/edited/deleted,
  123. run the utility LINGUA, like:
  124.  
  125. lingua english
  126.  
  127. and recompile (like you would also have to do if you had edited
  128. literal strings in your source code).
  129.  
  130. LINGUA creates two files: english.etf and ui_text.h (ETF stands for
  131. Encrypted Text File). The header file UI_TEXT.H must be included in the
  132. source file that takes care of the loading and unloading of the text
  133. at run time. Since this header is not language dependent, no
  134. recompilation for another language is necessary. It contains only
  135. defines for all identifiers as show below.
  136.  
  137. Example file ui_text.h:
  138.  
  139. /* ui_text.h */
  140.  
  141. int ui_loadtext(char *fname,char *vers);
  142. void ui_unloadtext(void);
  143. char *ui_filetext(unsigned pos);
  144. char **ui_filearray(unsigned pos);
  145. extern char **ui_text;
  146.  
  147. #define ZEROTH                         ui_text[0]
  148. #define FIRST                          ui_text[1]
  149. #define SECOND                         ui_text[2]
  150. #define THIRD                          (ui_text+3)
  151. #define EIGHTH                         ui_text[8]
  152. #define NINTH                          ui_filetext(0)
  153. #define TENTH                          ui_filetext(1)
  154. #define ELEVEN                         ui_filetext(2)
  155.  
  156. When your application is finished, make a copy of the original .TXT
  157. file and change the literal strings in the copy to another language.
  158. Be careful not to change the identifiers at the start of every line though!
  159. When you run LINGUA on this text file a new .ETF file is created
  160. (and also a ui_text.h, but this one is identical to the one in the
  161. original language).
  162.  
  163. In the application program, start with a call to ui_loadtext (in
  164. the UI_TEXT module). End the application program with a call to
  165. ui_unloadtext. Another language may be loaded at that point too.
  166. Lingua also writes a checksum at the start of the .ETF file. ui_loadtext
  167. returns 1 if the file was read and decoded successfully and the
  168. computed checksum is equal to the one in the file and 0 if not.
  169. You can then handle an error condition in your application (but
  170. in what language?).
  171.  
  172. Example file lingdemo.c (link with ui_text.c):
  173.  
  174. #include <stdio.h>
  175. #include <string.h>
  176. #include "ui_text.h"
  177.  
  178. int main(int argc,char *argv[])
  179. {
  180.    char filename[81],version[81];
  181.  
  182.    if (argc>3) return 1;
  183.    if (argc==3) strcpy(version,argv[2]); else version[0]='\0';
  184.    if (argc>=2) strcpy(filename,argv[1]); else strcpy(filename,"english");
  185.  
  186.    if (ui_loadtext(filename,version)) {
  187.       printf("%s",FIRST);
  188.       printf("%s",SECOND);
  189.       printf("%s",THIRD[0]);
  190.       printf("%s",THIRD[1]);
  191.       printf("%s",THIRD[2]);
  192.       printf("%s",THIRD[3]);
  193.       printf("%s",THIRD[4]);
  194.       printf("%s",EIGHTH);
  195.       printf("%s",NINTH);
  196.       printf("%s",TENTH);
  197.       printf("%s",ELEVEN);
  198.       ui_unloadtext();
  199.    } else puts("Fatal error");
  200.    return 0;
  201. }
  202.  
  203. Execute this example program by:
  204.  
  205. lingdemo <name of etf-file without extension>
  206.  
  207. e.g.:
  208.  
  209. lingdemo english
  210.  
  211. If so desired an optio